package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.TYearEffectInfo;
import cn.com.headfree.mouldshow.dao.TYearEffectInfoDao;
import cn.com.headfree.vo.simple.YearEffectInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tYearEffectInfoDao")
public class TYearEffectInfoDaoImpl extends BaseDaoImpl<TYearEffectInfo> implements TYearEffectInfoDao {


    @Override
    public List<YearEffectInfoVo> findByBaseorgId(String deptId) throws Exception{
        Object[] params = new Object[1];
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.rate_year_start,t.rate_year_end,t.rate_year,t.perfor_grade,t.resi_inte,t.cur_inte,u.`NAME` as user_name from t_year_effect_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.rate_year DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.rate_year_start,t.rate_year_end,t.rate_year,GET_DIC('PerformLevelRecentThreeYears',t.perfor_grade) as perfor_grade,t.resi_inte,t.cur_inte,u.`NAME` as user_name from t_year_effect_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.rate_year DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.rate_year_start,DATE_FORMAT(t.rate_year_start,'%Y-%m-%d %H:%i:%s') as rate_year_start_str,t.rate_year_end,DATE_FORMAT(t.rate_year_end,'%Y-%m-%d %H:%i:%s') as rate_year_end_str,t.rate_year,GET_DIC('PerformLevelRecentThreeYears',t.perfor_grade) as perfor_grade,t.resi_inte,t.cur_inte,u.xb_name as user_name from t_year_effect_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.rate_year DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(YearEffectInfoVo.class, sql.toString(), null, false, params);
    }
}
